<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/commons/jsp-head.jsp"%>
<%@ include file="/commons/html-head-easyui.jsp" %>
<script type="text/javascript" src="/js/etool/etool_curd.js"></script>
<script>
function serach()
{
	var searchParams=new Array();
	$.each( $("#search_dir input"), function(i, n){
			var val=$.trim($(n).val());
			var name=$(n).attr("name");
			if(val!=undefined && val!=null && val!='')
				{
				searchParams[name]=val;		
				}
	});
	$('#dg').datagrid('load',searchParams); 
}
</script>





<div style="margin-bottom: 2px">
	<div id="search_dir" class="easyui-panel" title="search" style="padding:10px;"  data-options="collapsible:true,maximizable:true,closable:true" fit="true">  
         <table width="100%" >
         <c:set var="count" value="0"></c:set>
         <c:forEach items="${columns}" var="item">
         	<c:if test="${count==0}"><tr></c:if> 
         		<td width="30%">
         			${item.name}:<input type="text" name="${item.name}">
         		</td>		
         	<c:if test="${count==2}"></tr></c:if> 
         	
         	<c:set var="count" value="${count+1}"></c:set>
         	
         	<c:if test="${count==3}">
         		<c:set var="count" value="0"></c:set>
         	</c:if>    	
         </c:forEach>
         </table>
         
         <button onclick="serach();">搜索</button>
	</div>
</div> 



<table id="dg" title="${target}" class="easyui-datagrid"
	style="width: 700px; height: 250px"
	url="/curd/read.action?target=${target}" toolbar="#toolbar"
	pagination="${pagination}" fitColumns="true" singleSelect="true"
	fit="true" pageList="${pageList}">
	<thead>
		<tr>
			<c:forEach items="${columns}" var="item">
				<th field="${item.name}" width="50">${item.name}</th>
			</c:forEach>
		</tr>
	</thead>
</table>
<div id="toolbar">
	<a href="javascript:void(0)" class="easyui-linkbutton"
		iconCls="icon-add" plain="true" onclick="newUser()">新建</a> <a
		href="javascript:void(0)" class="easyui-linkbutton"
		iconCls="icon-edit" plain="true" onclick="editUser()">编辑</a> <a
		href="javascript:void(0)" class="easyui-linkbutton"
		iconCls="icon-remove" plain="true" onclick="destroyUser()">删除</a>
</div>



<div id="dlg" class="easyui-dialog"
	style="width: 400px; height: 280px; padding: 10px 20px" closed="true"
	buttons="#dlg-buttons">
	<div class="ftitle">${target}</div>
	<form id="fm" method="post" novalidate>
		<c:forEach items="${columns}" var="item">
			<div class="fitem">
				<label>${item.name}:</label> <input name="${item.name}">
				<c:if test="${item.key == true &&  item.auto_increment == true}">
					<p>
						<font color="red">主键且自动增长,可不填</font>
					</p>
				</c:if>
			</div>
		</c:forEach>
		<!-- class="easyui-validatebox" validType="email" -->
		<!-- class="easyui-validatebox" required="true" -->
	</form>
</div>
<div id="dlg-buttons">
	<a href="javascript:void(0)" class="easyui-linkbutton"
		iconCls="icon-ok" onclick="saveUser()">Save</a> <a
		href="javascript:void(0)" class="easyui-linkbutton"
		iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
</div>






<!-- 中部：内容 -->

<script type="text/javascript">
	
</script>



<style type="text/css">
body{
	margin:0px;
	padding:0px
}
#fm {
	margin: 0;
	padding: 10px 30px;
}

.ftitle {
	font-size: 14px;
	font-weight: bold;
	padding: 5px 0;
	margin-bottom: 10px;
	border-bottom: 1px solid #ccc;
}

.fitem {
	margin-bottom: 5px;
}

.fitem label {
	display: inline-block;
	width: 80px;
}
</style>